<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>合同清单</title>
    <link rel="stylesheet" type="text/css" th:href="@{/easyui/themes/default/easyui.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/easyui/themes/icon.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/easyui/themes/color.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/easyui/demo/demo.css}">
    <script type="text/javascript" th:src="@{/easyui/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/easyui/jquery.easyui.min.js}"></script>
    <script type="text/javascript" th:src="@{/easyui/locale/easyui-lang-zh_CN.js}"></script>
</head>

<body style="padding: 0px">
<table id="dg" title="合同列表" class="easyui-datagrid" style="width:100%;height:800px"
       toolbar="#toolbar"
       pagination="true"
       striped="true"
       url="getOrdersInfo"
       rownumbers="true"
       fitColumns="true"
       singleSelect="true"
       fit="true"
       loadMsg="正在查询...">
    <thead>
    <tr>
        <th field="id" width="4%" >订单序号</th>
        <th field="orderNum" width="8%">委托收购协议号</th>
        <th field="createTime" width="8%">签订日期</th>
        <th field="status" width="5%" >审核状态</th>
        <th field="companyName" width="13%">甲方</th>
        <th field="supplierId" width="4%">供货人序号</th>
        <th field="supplierName" width="5%">供货人姓名</th>
        <th field="supplierIdNum" width="9%">供货人身份证号</th>
        <th field="bankName" width="4%" data-options="editor:'text'">开户行</th>
        <th field="branchBankName" width="6%" data-options="editor:'text'">支行</th>
        <th field="bankNum" width="10%">银行卡号</th>
        <th field="itemName" width="4%">品名</th>
        <th field="price" width="4%">价格</th>
        <th field="weight" width="4%">重量</th>
        <th field="startDate" width="7%">合同生效日期</th>
        <th field="endDate" width="7%">合同失效日期</th>
    </tr>
    </thead>
</table>
<div id="toolbar">
    <label>供应商:</label>
    <select class="easyui-combobox" name="company" id="company"
            style="width:250px"
            data-options="valueField:'code',textField:'name',
                            url:'/hetong/web/getCompany',
                            editable:true">
    </select>
    <label>货物:</label>
    <select class="easyui-combobox" name="item" id="item" style="width:100px">
        <option>废纸</option>
        <option>废钢</option>
    </select>
    <label>审核状态:</label>
    <select class="easyui-combobox" name="status" id="status"
            style="width:100px"
            data-options="valueField:'code',textField:'status',
                            url:'/hetong/web/getContractStatus',
                            editable:true">
    </select>
    <input id="fuzzySearch" class="easyui-textbox" style="width:250px" prompt="请输入关键字">
    <a  href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="searchInfo()">搜索</a>
</div>
</body>

<script type="text/javascript">
    //刷新
    function reload() {
        $('#dg').datagrid('reload');
    }


    //查看合同
    function openPDF()
    {
        var row = $('#dg').datagrid('getSelected');
        var orderId=row.id;
        if (row){
            var url="../../../hetong/download?orderId="+orderId+"&model=0";
            window.open(url);
        }
    }
    //搜索
    function searchInfo() {
        var company=$("#companySearch").combobox("getText");
        var status=$("#statusSearch").combobox("getText");
        var item=$("#itemSearch").combobox("getText");
        var info=document.getElementById("fuzzySearch").value;
        var page = $("#dg").datagrid('options').pageNumber;
        var rows = $("#dg").datagrid('options').pageSize;
        var options = $('#dg').datagrid('getPager').data("pagination").options;
        //总记录数
        var total = options.total;
        $('#dg').datagrid('loading');
        $.ajax({
            url:"../../../hetong/web/searchOrder",
            type:"post",
            data:JSON.stringify(
                {
                    total:total,
                    page:page,
                    rows:rows,
                    status:status,
                    item:item,
                    company:company,
                    info:info
                }
            ),
            datatype:"josn",
            contentType:"application/json",
            success:function(result){
                if(result.status===200)
                {
                    $('#dg').datagrid('loaded');
                    $('#dg').datagrid('loadData',result.data);
                }
                else
                {
                    $('#dg').datagrid('loaded');
                    alert(result.message);
                }

            }
        });

    }


    //模糊搜索
    function searchFuzzyOrder() {
        var info=document.getElementById("fuzzySearch").value;
        var page = $("#dg").datagrid('options').pageNumber;
        var rows = $("#dg").datagrid('options').pageSize;
        var options = $('#dg').datagrid('getPager').data("pagination").options;
        //总记录数
        var total = options.total;
        $('#dg').datagrid('loading');
        $.ajax({
            url:"../../../hetong/web/searchFuzzyOrder?info="+info+'&rows='+rows+'&page='+page,
            type:"post",
            success:function(result){
                if(result.status===200)
                {
                    $('#dg').datagrid('loaded');
                    $('#dg').datagrid('loadData',result.data);
                }
                else
                {
                    $('#dg').datagrid('loaded');
                    alert(result.message);
                }

            }
        });
    }
</script>






</html>